package com.shine.icis.hbean;

/**
 * 综合ETL运行日志、环境检查日志、数据质量检查日志
 */
import java.io.Serializable;

import com.shine.icis.config.SysCodeDictLoader;
import com.shine.icis.util.Tools;

public class ProgExeLog implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 2415088348566987884L;
	
	public static final int ETL_PROC_ID_EXCRACT = 1;//抽取
	public static final int ETL_PROC_ID_LOAD = 2;//加载
	public static final int ETL_PROC_ID_METADATACHECK = 3;//质检
	public static final int ETL_PROC_ID_TRANSFORM = 4;//转换
	public static final int ETL_PROC_ID_GENDATA= 5;//生成数据
	public static final int ETL_PROC_ID_DATACHECK = 6;//核对
	public static final int ETL_PROC_ID_GENFILE = 7;//生成文件
	public static final int ETL_PROC_ID_DATAARCH = 8;//归案
	
	public static final char ETL_TYPE_PRO = '0';//整个过程
	public static final char ETL_TYPE_JOB = '1';//任务过程
	
	private	Long logID;
	private	Integer etlProcID;//过程ID
	private	Integer datasetTypeID;//数据集类型ID
	private	char etlType;
	private	int operDate;
	private	int operTime;
	private char runStatus;//任务运行状态:1表示开始，2表示成功，3表示失败
	
	
	public Long getLogID() {
		return logID;
	}
	public void setLogID(Long logID) {
		this.logID = logID;
	}
	public Integer getEtlProcID() {
		return etlProcID;
	}
	
	public String getEtlProcText() {
		if (etlProcID == null) {
			return "";
		}
 		return SysCodeDictLoader.getInstance().getEtlProcOptionText(etlProcID.toString());
	}
	
	public void setEtlProcID(Integer etlProcID) {
		this.etlProcID = etlProcID;
	}
	public Integer getDatasetTypeID() {
		return datasetTypeID;
	}
	
	public String getDatasetTypeText() {
		if (datasetTypeID == null) {
			return "";
		}
 		return SysCodeDictLoader.getInstance().getBizSystemOptionText(datasetTypeID.toString());
	}
	
	public void setDatasetTypeID(Integer datasetTypeID) {
		this.datasetTypeID = datasetTypeID;
	}
	public char getEtlType() {
		return etlType;
	}
	public void setEtlType(char etlType) {
		this.etlType = etlType;
	}
	public int getOperDate() {
		return operDate;
	}
	public void setOperDate(int operDate) {
		this.operDate = operDate;
	}
	public int getOperTime() {
		return operTime;
	}
	public void setOperTime(int operTime) {
		this.operTime = operTime;
	}
	public char getRunStatus() {
		return runStatus;
	}
	public void setRunStatus(char runStatus) {
		this.runStatus = runStatus;
	}
	
	public String getFormatOperDate() {
		//20100909 -> 2010-09-09
		StringBuffer sb = new StringBuffer();
		sb.append(operDate);
		if (sb.length() != 8) {
			return "";
		}
		return sb.insert(6, "-").insert(4, "-").toString();
	}
	
	public String getFormatOperTime() {
		//121200 -> 12:12:00
		StringBuffer sb = new StringBuffer();
		sb.append(Tools.getFixedNum(operTime, 6));
		return sb.insert(4, ":").insert(2, ":").toString();
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((logID == null) ? 0 : logID.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final ProgExeLog other = (ProgExeLog) obj;
		if (logID == null) {
//			if (other.logID != null)
				return false;
		} else if (!logID.equals(other.logID))
			return false;
		return true;
	}
	
}
